#include "stdafx.h"
#include "InstructionListTableModel.h"
#include <QPushButton>
#include <QAbstractItemModel>

QInstructionListTableModel::QInstructionListTableModel(QObject *parent)
	: QRecordTableModel(parent)
{

}

QInstructionListTableModel::~QInstructionListTableModel()
{

}
//
//QVariant QInstructionListTableModel::headerData(int section, Qt::Orientation orientation, int role) const
//{
//	if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
//	{
//		if (dsRecords.colCount() > section)
//		{
//			short col = dsRecords.showRecords().at(section);
//			return dsRecords.colRecords().at(col)->alias;
//		}
//	}
//	return QVariant();
//}

// QModelIndex QInstructionListTableModel::index(int row, int column, const QModelIndex & parent /*= QModelIndex()*/) const
// {
// 	if (!hasIndex(row, column, parent))
// 		return QModelIndex();
// 
// 	return createIndex(row, column, row);
// }
// 
QVariant QInstructionListTableModel::data(const QModelIndex &index, int role) const
{
	if (role == Qt::DecorationRole && index.column() == columnCount() - 1)
	{
		const QString imageSceneNode("image:app/instruction/modify.gif");
		return QPixmap(imageSceneNode);
	}

	if (role != Qt::DisplayRole || !index.isValid()) return QVariant();

	return display(index.column(), dsRecords.showData(index.row(), index.column()));
}
// 
// QModelIndex QInstructionListTableModel::parent(const QModelIndex & child) const
// {
// 	return QModelIndex();
// }
